package fr.epsi.activities.absence;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.example.MyLittleHotel.R;
import fr.epsi.BDD.BDD;

import java.sql.SQLException;

/**
 * Created by Florent Baudon on 02/06/2014.
 */
public class FicheAbsenceActivity extends Activity {

    TextView emp, motif, deb, fin;
    Cursor infoAbsence;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ficheabsencelayout);

        Bundle b = this.getIntent().getExtras();

        emp = (TextView)findViewById(R.id.ficheAbsenceEmp);
        motif = (TextView)findViewById(R.id.ficheAbsenceMotif);
        deb = (TextView)findViewById(R.id.ficheAbsenceDeb);
        fin = (TextView)findViewById(R.id.ficheAbsenceFin);

        try{
            BDD bdd = new BDD();
            bdd.open(this);
            infoAbsence = bdd.getAbsencesMotifNom(b.getString("motif"), b.getString("nom"));
        }catch (SQLException e){
            e.printStackTrace();
        }
        Log.i("Littlehotelùmzkqmdsomsq", infoAbsence.getColumnCount() + "      " + infoAbsence.getCount());
        if(infoAbsence!=null && infoAbsence.moveToFirst()){
            emp.setText(infoAbsence.getString(1) + " " + infoAbsence.getString(2));
            motif.setText(infoAbsence.getString(3));
            deb.setText("Du " +(infoAbsence.getString(4)).substring(0, 10));
            fin.setText("Au " + (infoAbsence.getString(5)).substring(0, 10));
        }
    }
}